Repository navigation
perf(simd,quantization,vec0): x86 runtime dispatch, fused RaBitQ popcount, incremental vec0 ANN, SearchStats & invariants - #2
Merged
Conversation
…itQ popcount - Wire SQLITE_VEC_X86_RUNTIME_DISPATCH (x86::l2_squared_avx2) in distances::l2_squared_distance() - Store inv_scales on LVQ8Store/LVQ4Store, add AVX2/runtime-dispatch kernels, and compare squared distances in quantized beam search (no per-hop sqrt) - Replace 256-entry LUT popcount in RaBitQ with uint64 std::popcount + fused 4-plane kernel and precomputed uint16_t code_popcount - Fix signed int16 overflow in l2_distance_int8_neon using widening vsubl_s8 + vmlal_s16 - Install simd/x86_dispatch.hpp in meson.build
- Maintain ann_index incrementally on INSERT/UPDATE/DELETE when ann_ready is true (compact only on needs_compaction() or node ID reuse, with invalidation fallback on error) - Cache prepared statements on Vec0Table for xUpdate and xColumn fallback, resetting/clearing bindings per call and finalizing on xDisconnect/xDestroy
…rity test suite - Add optional SearchStats* out-parameter (hops, distance_evals, rerank_evals, filter_rejections) to HNSW and quantized search methods with zero overhead when nullptr - Add tests/test_invariants.cpp covering L2/Hamming symmetry & triangle inequality, unaligned float/int8 spans, odd dimensions (1..769), SIMD-vs-scalar parity for L2/LVQ8/LVQ4/RaBitQ, SearchStats telemetry, and incremental vec0 insert/update/delete recall parity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
x86-64 runtime SIMD dispatch & RaBitQ popcount
SQLITE_VEC_X86_RUNTIME_DISPATCH(x86::l2_squared_avx2) branch todistances::l2_squared_distance().inv_scalesonLVQ8StoreandLVQ4Store, added compile-time AVX2 and runtime-dispatched AVX2+FMA kernels, and switched quantized beam search (HNSWQuantizedSearch) to compare squared distances directly (eliminating per-hopstd::sqrt).RaBitQwithuint64_tstd::popcount, added a fused single-pass 4-plane kernel (and_popcount_4planesfor both NEON anduint64_t), and precomputeduint16_t code_popcountat encode time.int16_toverflow bug inl2_distance_int8_neon(caught by the new invariant test suite) by using wideningvsubl_s8+vmlal_s16.simd/x86_dispatch.hpptoinstall_headersinmeson.build.Incremental
vec0ANN maintenance & cached prepared statementsvec0Updateto maintainann_indexincrementally onINSERT/UPDATE/DELETEwhenann_readyis true, triggeringcompact()only whenneeds_compaction()(or when replacing an existing/soft-deleted node ID), with fallback invalidation on error.Vec0TableforxUpdateandxColumn, resetting/clearing bindings per call and finalizing onxDisconnect/xDestroy.Optional HNSW
SearchStatstelemetry & invariant test suiteSearchStats* stats = nullptrout-parameter (hops,distance_evals,rerank_evals,filter_rejections) to HNSW and quantized search APIs (zero overhead whennullptr).tests/test_invariants.cppwired intotests/meson.buildcovering L2/Hamming symmetry & triangle inequality, unalignedfloat*/int8_t*spans, odd dimensions (1, 7, 15, 17, 31, 33, 385, 769), SIMD-vs-scalar parity forl2_squared_distance,LVQ8Store,LVQ4Store, andRaBitQStore,SearchStatstelemetry, and incrementalvec0insert/update/delete recall parity.Verification
meson setup build-hillclimb -Denable_tests=true -Denable_examples=false -Denable_benchmarks=false && meson compile -C build-hillclimb -j4 && meson test -C build-hillclimb --print-errorlogs: 12/12 tests passed (arm64 NEON + DotProd).clang++ -std=c++20 -target x86_64-apple-macos13 -fsyntax-onlyverified clean compilation of bothSQLITE_VEC_X86_RUNTIME_DISPATCHand compile-time-mavx -mavx2 -mfmapaths.